/**
 * 页面js
 */
//点击左边的按钮使最左边的菜单只显示图标不显示菜单文字
function left_width(url){
	$('#icon1').click(function(){
		var type=$(this).attr('type');
		if(type != 1){
			$('.left').addClass('left-o');
			$('.right').addClass('right-o');
			$('.l-left').addClass('l-left-o');
			$('.l-font').hide();
			$(this).attr({type:1});
			var data ={type:1}
			$.post(url,data)
		}else{
			$('.left').removeClass('left-o');
			$('.right').removeClass('right-o');
			$('.l-left').removeClass('l-left-o');
			$('.l-font').show();
			$(this).attr({type:''});
			var data={type:0};
			$.post(url,data)
		}
	})
}
//上传单张图片
function upload_a_img(upload_url){
	var obj = $('.upload input');
	//var upload_url = '{:U("Ajax/upload")}';
	//var upload_url='http://img.baicaibuy.cn/Upload/upload';
	obj.wrap("<form id='myupload' action='"+upload_url+"' method='post' enctype='multipart/form-data'></form>");
	obj.change(function(){
		obj.parent('form').ajaxSubmit({
			dataType:  'json',
			success: function(data) {
				if(data.code==1){
					var img_url = data.result.url;
					//var url = "{:U('Ajax/updateimg')}";
					parent.layer.msg('上传图片成功',{time:1000},function(){
						var html='<img height="70px" style="padding:2px 0" src="'+img_url+'"/>';
						obj.parent().prev('.upload-img-box').html(html);
						obj.attr('src', img_url);
					})
				}else{
					parent.layer.msg('上传图片失败');
				}
			},
		})
	});
}
//管理员列表中鼠标放上去图片变大
function big_img1(){
	var x = 10;
	var y = -150;
	$('.head_pic').each(function(){
		var obj = $(this);
		obj.mouseover(function(e){
			var tooltip = "<div id='tooltip'><img src='" + this.src + "' width='250px' height='250px' /></div>";
			$("body").append(tooltip);
			$("#tooltip").css({
						"position":'absolute',
						"top": (e.pageY + y) + "px",
						"left": (e.pageX + x) + "px"
					}).show("fast");
		}).mouseout(function(e){
			$("#tooltip").remove();
		}).mousemove(function(e){
			$("#tooltip").css({
				"top": (e.pageY + y) + "px",
				"left": (e.pageX + x) + "px"
			});
		});
	});
}